import pandas as pd
import os

def export_sheets_as_files(input_file, sheet_names, output_dir):
    if not os.path.exists(output_dir):
        os.makedirs(output_dir)

    for sheet in sheet_names:
        df = pd.read_excel(input_file, sheet_name=sheet)
        output_path = os.path.join(output_dir, f"{sheet}.xlsx")
        df.to_excel(output_path, index=False, sheet_name=sheet)
        print(f"Sheet '{sheet}' 已导出至 {output_path}")

# 示例用法
input_file = r"E:\git_dtsw_jx\net-open-api\jiangxi\doc\网络数据OpenAPI（Net-OpenAPI）模型v1.0-江西项目适配方案-5G-DPI-http.xlsx"
sheet_names = ["aggr.4.1.5"]
output_dir = r"E:\python_out\output_0801"

export_sheets_as_files(input_file, sheet_names, output_dir)

